
<!DOCTYPE HTML>
<html>
<head>
    <title>枣阳市第二人民医院信息管理系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../assets/css/dpl-min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/css/main-min.css" rel="stylesheet" type="text/css" />
</head>
<body>


<!--<div class="header">

    <div class="dl-title">
        <img src="/chinapost/Public/assets/img/top.png">
    </div>

    <div class="dl-log">欢迎您，<span class="dl-log-user">张三</span><a href="/chinapost/index.php?m=Public&a=logout" title="退出系统" class="dl-log-quit">[退出]</a>
    </div>
</div>-->
<div class="content">
    <div class="dl-main-nav">
        <div class="dl-inform"><div class="dl-inform-title"><s class="dl-inform-icon dl-up"></s></div></div>
        <ul id="J_Nav"  class="nav-list ks-clear" style="float:left">
            <!--<li class="nav-item dl-selected"><div class="nav-item-inner nav-home">信息采编系统</div></li>-->
			<li style=" color:#fff; font-size:20px; margin-top:10px; margin-left:20px;">山东省第二人民医院管理平台</li>
		</ul>
		<div  style="float:right; color:#fff;">欢迎您，<span class="dl-log-user">user</span><button onclick="logout()" title="退出系统" class="dl-log-quit">[退出]</button></div>
    </div>
	
    <ul id="J_NavContent" class="dl-tab-conten">
    </ul>
</div>
<script type="text/javascript" src="../assets/js/jquery-1.6.js"></script>
<script type="text/javascript" src="../assets/js/bui.js"></script>
<script type="text/javascript" src="../assets/js/common/main-min.js"></script>
<script type="text/javascript" src="../assets/js/config-min.js"></script>


<script>
    let userName;
    let resList;
    //页面加载完毕之后
    $(function(){
        userName = parseUrl(window.location.href).userName;
        $(".dl-log-user").html(userName);
        $.ajax({
            type: "GET",
            url: "/menu",
            dataType:"json",
            success: function (vo) {
                console.log("获取菜单")
                resList = vo.list;
                onload();
            }
        })
    });
    //解析路径上的参数
    function parseUrl(url){
        if(url.indexOf("?") == -1) {
            return {};
        }
        var query = url.split("?")[1];
        query = query.split("#")[0]
        var queryArr = query.split("&");
        var obj = {};
        queryArr.forEach(function(item){
            var key = item.split("=")[0];
            var value = item.split("=")[1];
            obj[key] = decodeURIComponent(value);
        });
        return obj;
    }

    function onload() {
        BUI.use('common/main',function(){
            resList = resList.map(item=>{
                return item+1;
            })
            var config = [
            {id:'1',menu:[
            {text:'快速通道',items:[
            {id:'2',text:'挂号信息管理',href:'/pages/registration/index.html'},
            {id:'3',text:'住院办理',href:'/pages/hospital/index.html'},
            {id:'4',text:'住院结算',href:'/pages/hospital/account.html'},
            {id:'5',text:'在院发药',href:'/pages/hospital/dispensing.html'},
            {id:'6',text:'药品管理',href:'/pages/medicine/index.html'},
            {id:'7',text:'收费项目登记',href:'/pages/hospital/charge2.html'},
            {id:'8',text:'收费项目管理',href:'/pages/hospital/charge.html'},
            /** 扩展
            {id:'9',text:'月营业额统计',href:''},
            {id:'10',text:'年营业额统计',href:''},
            **/
            {id:'9',text:'门诊医生管理',href:'/pages/doctor/index.html'},
            {id:'10',text:'用户管理',href:'/pages/User/index.html'},
            {id:'11',text:'角色管理',href:'/pages/Role/index.html'},
            {id:'12',text:'资源管理',href:'/pages/Resource/index.html'},
            {id:'13',text:'密码管理',href:'/pages/User/password.html'}
            ]}

            ]}
            ];
            let itemList = [];
            config[0].menu[0].items.forEach(item=>{
                let flag = false;
                resList.forEach(element=>{
                    if(item.id == element){
                        flag = true
                    }
                })
                if(flag == true){
                    itemList.push(item)
                }
            })
            config[0].menu[0].items = itemList;
            new PageUtil.MainPage({
                modulesConfig : config
            });
        });
    }
    //登出
    function logout() {
        console.log("開始退出")
        $.ajax({
            type: "GET",
            url: "/logout",
            dataType: "json",
            success: function (){
                alert("登出成功");
            }
        })
        location.replace("/pages/login.html")
    }
</script>
</body>
</html>